package com.spzx.product.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.pagehelper.PageHelper;
import com.spzx.domain.Brand;
import com.spzx.product.service.IBrandService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Tag(name = "商品管理接口")
@RestController
@RequestMapping("/brand")
public class BrandController {

    @Autowired
    private IBrandService brandService;

    @Operation(summary = "所有品牌查询")
    @GetMapping("getBrandAll")
    public IPage<Brand> getBrandAll(){
        IPage<Brand> list  = brandService.getBrandAll();
        return list;
    }
    @Operation(summary = "根据ID品牌详细信息")
    @GetMapping(value = "/{id}")
    public  Brand getInfo(@PathVariable("id") Long id){
        return brandService.selectBrandById(id);
    }

    @Operation(summary = "添加品牌")
    @PostMapping
    public int add(@RequestBody Brand brand){
        return brandService.insertBrand(brand);
    }

    @Operation(summary = "修改品牌")
    @PutMapping
        public int edit(@RequestBody Brand brand){
        return brandService.updateBrand(brand);
    }

    @Operation(summary = "根据ID批量删除品牌")
    @DeleteMapping("/{ids}")
    public int remove(@PathVariable Long[] ids){
        return brandService.deleteBrandById(ids);
    }


}
